import java.util.HashMap;
public class BikeFactory {
    public static HashMap<String,Bike> bikeMap=new HashMap<>();
    public static Bike getBike(String color,String type){
        String key=color+"_"+type;
        if(bikeMap.containsKey(key)){
            return bikeMap.get(key);
        }else {
            Bike bike=null;
            //没有，创建并放入缓存
            if("BlueBike".equals(type)){
                bike=new SharedBikeBlue(color,1);
            }else if ("YellowBike".equals(type)){
                bike=new SharedbikeYellow(color,2);
            }
            bikeMap.put(key,bike);
            return bike;
        }
    }
}
